#include <stdio.h>
#include <string.h>

int lengthOfLastWord(char* s)
{
    size_t len = strlen(s);
    int count = 0;
    for(int i = len - 1;i >= 0;i--)
    {
        if(s[i] != ' ')
        {
            count++;
            if(s[i - 1] == ' ')
                return count;
        }
       
    }
}

int main()
{
    char s[] = "  i   am   from  nanjing ";
    int n = lengthOfLastWord(s);
    printf("%d\n",n);
    return 0;
}